<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Mine\MineModel;

/**
 * @property int $uid 
 * @property int $group_id 分组ID：0=未分组
 * @property int $data_scope 权限范围：0=仅自己 1=全部子账号 2=自定义范围
 * @property string $data_scope_extra 权限范围额外参数
 * @property int $data_scope_allow 权限范围是否允许允许查看/管理主账号下登录的企微号0=否 1允许
 * @property int $seat_quota 席位可用数量：-1不限
 * @property int $expire_time 使用有效期：0=永久有效
 * @property-read null|ChUserGroup $group 
 */
class ChUserExt extends MineModel
{
    public bool $incrementing = false;
    protected string $primaryKey = 'uid';
    public bool $timestamps = false;
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_user_ext';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['uid', 'group_id', 'data_scope', 'data_scope_extra', 'data_scope_allow', 'seat_quota', 'expire_time'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['uid' => 'integer', 'group_id' => 'integer', 'data_scope' => 'integer', 'data_scope_allow' => 'integer', 'seat_quota' => 'integer', 'expire_time' => 'integer'];

    public function group(): \Hyperf\Database\Model\Relations\HasOne
    {
        return $this->hasOne(ChUserGroup::class, 'id', 'group_id');
    }
}
